﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Gift.Model;
using Gift.DAL;


namespace WebSite.cn.service
{
    public partial class gymnasium : BasePage
    {
        DALGoods theGoods = new DALGoods();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string WriterGoodsHtml()
        {
            StringBuilder sGoodsHtml = new StringBuilder();

            DataTable dtGoods = theGoods.GetList(" isnull(visible,0)=1 and isnull(isSale,0)=1 and termsId in(select id from tbTerms where termsName like '%文体健身%')  order by goodsOrder ").Tables[0];

            int iRowIndex = 0;
            for (int i = 0; i < dtGoods.Rows.Count; i++)
            {
                if (i % 3 == 0)
                {
                    sGoodsHtml.Append("<tr>");

                }
                sGoodsHtml.AppendFormat("  <td class=\"card_pic\"><img src=\"/uploadfile/product/{0}\"  "
                                         + " onmouseover=\"this.className='htmer_img'\" onmouseout=\"this.className=\'htmer_img_none'\" /> </td> "
                                        + " <td  class=\"card_inst\"><p class=\"list_card_title\">{1}</p><p><em>兑换价：{2}福点</em></p> "
                                        + " <p><a href=\"{3}\" target=\"_self\" ><img src=\"/cn/serviceImages/submit.gif\" class=\"img_submit\" alt=\"\" /></a> </p> "
                                        + " </td> "
                                        , dtGoods.Rows[i]["smallPic"].ToString()
                                        , dtGoods.Rows[i]["goodsName"].ToString()
                                        , dtGoods.Rows[i]["changePoints"].ToString()
                                        , "/cn/goodsDetail.html?gid=" + dtGoods.Rows[i]["goodsId"].ToString()
                                        );
                iRowIndex++;
                if (iRowIndex % 3 == 0)
                {
                    sGoodsHtml.Append("</tr>");
                }
            }
            if (dtGoods != null)
            {
                if (dtGoods.Rows.Count % 3 == 1)
                {
                    sGoodsHtml.Append("<td column='4'></td></tr>");
                }
                else if (dtGoods.Rows.Count % 3 == 2)
                {
                    sGoodsHtml.Append("<td ></td><td></td></tr>");
                }
            }
            return sGoodsHtml.ToString();

        }
    }
}